<?php 

require("../include/config.php");
require("../API/php/fonctions.php");
require("../API/php/header.php");

// phpsql/mysql_setValueAffectation.php?date=2011-11-21&user=FRO&value=10

// IN obligatoire
$arrayGet = array(
    "date" => null,
    "user" => null,
    "value" => null
);

$arrayValeur = recupGet($arrayGet, $bolDecode);

if($arrayValeur["error"] == null){
	// CONNECION SQL
	$db = mysql_connect($host, $base, $mdp)  or die('Erreur de connexion '.mysql_error());

	// CONNECION BASE
	mysql_select_db($base,$db)  or die('Erreur de selection '.mysql_error()); 

	$sql = "UPDATE `affectation` SET `".$arrayValeur["user"]."` = '".$arrayValeur["value"]."' 
	WHERE `date` = STR_TO_DATE('".$arrayValeur["date"]."','%Y-%m-%d');";
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// DECONNECION SQL
	mysql_close();
}else{
	echo "ERROR:".$arrayValeur["error"];
}

?>